import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getHot } from "../api/index.js";
import { getYingyuan } from "../api/index.js";
import { getDaiying } from "../api/index.js";
import { getClassical } from "../api/index.js";
import { getTuijian } from "../api/index.js";
import { getSukan } from "../api/index.js";
import { getXinpian } from "../api/index.js";
import { getLittlemv } from "../api/index.js";

export const useHotStore = defineStore('hot', () => {
    const hots = ref([])
    const yinfyuans = ref([])
    const daiyings = ref([])
    const classical = ref([])
    const tuijian = ref([])
    const sukan = ref([])
    const xinpian = ref([])
    const littlemv = ref([])

    async function updateHot() {
        const { data } = await getHot();
        hots.value = data.data.hot;
        // return data
        console.log('hots', hots);
    }

    async function updateYingyuan() {
        const { data } = await getYingyuan();
        yinfyuans.value = data.cinemas.cinemas;
        // return data
        // console.log('hots', hots);
    }

    async function updateDaiying() {
        const { data } = await getDaiying();
        daiyings.value = data.classicMovies.list;
        // return data
        // console.log('daiyings', daiyings);
    }

    async function updateClassical() {
        const { data } = await getClassical();
        classical.value = data.classicMovies.list;
        // return data
        // console.log('classical', classical);
    }

    async function updateTuijian() {
        const { data } = await getTuijian();
        tuijian.value = data.data.feeds;
        // return data
        // console.log('classical', classical);
    }

    async function updateSukan() {
        const { data } = await getSukan();
        sukan.value = data.data.feeds;
        // return data
        // console.log('classical', classical);
    }

    async function updateXinpian() {
        const { data } = await getXinpian();
        xinpian.value = data.data.feeds;
        // return data
        // console.log('classical', classical);
    }

    async function updateLittlemv() {
        const { data } = await getLittlemv();
        littlemv.value = data.data.feeds;
        // return data
        // console.log('littlemv', littlemv);
    }


    return { hots, yinfyuans, daiyings, classical, tuijian, sukan, xinpian, littlemv, updateHot, updateYingyuan, updateDaiying, updateClassical, updateTuijian, updateSukan, updateXinpian, updateLittlemv }
})